﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QL_Nha_Sach_Phuong_Nam
{
    class Cxulytacgia
    {
        private CDuLieu data;

        public Cxulytacgia()
        {
            data = CDuLieu.khoitao();
        }

        #region các hàm xử lý

        //tim theo ten
        public List<TacGia> TimTacgiatheoten(string tentg)
        {
            List<TacGia> dstg = new List<TacGia>();
            foreach (TacGia tg in getdsTacgia())
            {
                if (tg.TacGiaName.Contains(tentg))
                    dstg.Add(tg);
            }
            return dstg;
        }

        //tim theo ma
        public TacGia TimTacgiatheoma(string ma)
        {
            TacGia tg = new TacGia();
            foreach (TacGia tacgia in getdsTacgia())
            {
                if (tacgia.TacGiaNo == ma)
                    tg = tacgia;
            }
            return tg;
        }

        //them tac gia
        public void ThemTacgia(TacGia tg)
        {
            data.ThemTacgia(tg);
        }

        //xoa tacgia
        public void XoaTacgia(string ma)
        {
            data.XoaTacgia(ma);
        }
    
        //sua tac gia
        public void SuaTacgia(TacGia tg)
        {
            data.SuaTacgia(tg);
        }

        //get danh sach tac gia
        public List<TacGia> getdsTacgia()
        {
            return data.getdsTacGia();
        }
        #endregion
    }
}
